#pragma once

#include <WinSock2.h>

class Binary {
public:
    class LittleEndian {
    public:
        static uint16_t Uint16(const char* b) {
            return uint16_t(b[0] | b[1] << 8u);
        }

        static void PutUint16(char* b, uint16_t v) {
            b[0] = static_cast<char>(v);
            b[1] = v >> 8;
        }

        static int16_t Int16(const char* b) {
            return int16_t(b[0] | b[1] << 8u);
        }

        static void PutInt16(char* b, int16_t v) {
            b[0] = static_cast<char>(v);
            b[1] = v >> 8;
        }

        static uint32_t Uint32(const char* b) {
            return u_int(b[0] | b[1] << 8 | b[2] << 16 | b[3] << 24);
        }

        static void PutUint32(char* b, uint32_t v) {
            b[0] = static_cast<char>(v);
            b[1] = v >> 8;
            b[2] = v >> 16;
            b[3] = v >> 24;
        }
    };
};
